package com.dtjd.playcoinmonkey.adapter;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import com.bumptech.glide.Glide;
import com.dtjd.playcoinmonkey.bean.RecommendListBean;
import com.dtjd.playcoinmonkey.databinding.ItemHomeBinding;
import com.dtjd.playcoinmonkey.databinding.ItemRecommendBinding;
import com.dtjd.playcoinmonkey.R;
import java.util.List;
public class RecommendListAdapter extends ArrayAdapter<RecommendListBean> {
    private final Activity context;
    public RecommendListAdapter(Activity context, List<RecommendListBean> objects){
        super(context, R.layout.item_recommend,objects);
        this.context=context;
    }
    @SuppressLint("SetTextI18n")
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        RecommendListBean bean = getItem(position);
        @SuppressLint("ViewHolder") ItemHomeBinding itemHomeBinding=ItemHomeBinding.inflate(LayoutInflater.from(context));

        itemHomeBinding.itemHomeOperate.setVisibility(View.GONE);
        itemHomeBinding.itemHomeCancelCollect.setVisibility(View.GONE);
        itemHomeBinding.itemHomeThaw.setVisibility(View.GONE);


        itemHomeBinding.itemHomeIcon.setImageResource(R.mipmap.ic_launcher);

        if ( bean.imgs.equals("")){
            itemHomeBinding.itemHomeImg.setVisibility(View.GONE);
        }else {
            Glide.with(context).load(bean.imgs).placeholder(R.drawable.loading).error(R.drawable.loaderr).into(itemHomeBinding.itemHomeImg);
            itemHomeBinding.itemHomeImg.setVisibility(View.VISIBLE);
        }

        itemHomeBinding.itemHomeView.setVisibility(View.GONE);
        itemHomeBinding.itemHomeTitle.setText(bean.bp_title);
        itemHomeBinding.itemHomeName.setText(bean.wb_nickname);
        itemHomeBinding.itemHomeContent.setText(bean.bp_content);
        itemHomeBinding.itemHomeTime.setText(bean.time);
return itemHomeBinding.getRoot();
    }
}
